package com.ushine.web.template.authority.model;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ushine.web.base.model.base.BasePermissionBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedBy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author: yls
 * @Date: 2021/3/3 9:33
 * @Description: 员工表
 * @Version 1.0
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@ApiModel(description = "员工表")
@Table(name = "t_cp_data_staff")
@org.hibernate.annotations.Table(appliesTo = "t_cp_data_staff", comment = "员工表")
@TableName(value = "t_cp_data_staff")
public class StaffDO extends BasePermissionBO implements Serializable {
    /**
     * 编号
     * JsonFormat(shape = JsonFormat.Shape.STRING) 解决前台js接收雪花id精度丢失问题
     */
    @Id
    @CreatedBy
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty("编号")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Column(name = "id", columnDefinition = "bigint comment '编号'")
    private Long id;

    /**
     * 用户名
     */
    @ApiModelProperty("用户名")
    @Column(name = "username", columnDefinition = "varchar(32) comment '用户名'")
    @NotBlank(message = "用户名不能为空")
    private String username;

    /**
     * 密码
     */
    @ApiModelProperty("密码")
    @Column(name = "password", columnDefinition = "varchar(32) comment '密码'")
    @NotBlank(message = "密码不能为空")
    private String password;

    /**
     * 显示名称
     */
    @ApiModelProperty("显示名称")
    @Column(name = "true_name", columnDefinition = "varchar(32) comment '显示名称'")
    @NotBlank(message = "真实姓名不能为空")
    private String trueName;

    /**
     * 状态
     */
    @ApiModelProperty("状态")
    @Column(name = "status", columnDefinition = "tinyint comment '状态'")
    private Integer status;


    /**
     * 所属省
     */
    @ApiModelProperty("所属国")
    @Column(name = "country", columnDefinition = "varchar(32) comment '所属国'")
    private String country;

    /**
     * 所属省
     */
    @ApiModelProperty("所属省")
    @Column(name = "province", columnDefinition = "varchar(32) comment '所属省'")
    private String province;

    /**
     * 所属市
     */
    @ApiModelProperty("所属市")
    @Column(name = "city", columnDefinition = "varchar(32) comment '所属市'")
    private String city;

    /**
     * 所属单位
     */
    @ApiModelProperty("所属单位")
    @Column(name = "company", columnDefinition = "varchar(32) comment '所属单位'")
    private String company;

    /**
     * 所属岗位
     */
    @ApiModelProperty("所属岗位")
    @Column(name = "post_id", columnDefinition = "bigint comment '所属岗位'")
    private Long postId;

    /**
     * 电话
     */
    @ApiModelProperty("电话")
    @Column(name = "mobile", columnDefinition = "varchar(32) comment '电话'")
    @Pattern(regexp = "^(\\S*|1[0-9]{10})$", message = "手机号码格式有误")
    private String mobile;


    /**
     * 逻辑删除
     * TableField => select:false (在查询的时候排除该字段)
     */
    @TableLogic
    @TableField(value = "is_deleted", fill = FieldFill.INSERT, select = false)
    @ApiModelProperty(value = "逻辑删除", example = "0")
    @Column(name = "is_deleted", columnDefinition = "datetime comment '删除标记=> 不为null：已删除，为空：未删除'")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime deleted;

}
